package com.cmsky.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/p/")
public class PriviligeController {
	private static String className = ThridCmsQueryController.class.getName();
	private static Logger priviligeControllerLogger = Logger.getLogger(className);
	
	@RequestMapping("/index")
	public ModelAndView index(HttpServletRequest request,HttpServletResponse response,Model model){
		ModelAndView view = new ModelAndView("/p/index");
		priviligeControllerLogger.info("<|>"+className+"<|>index<|><|><|>");
		return view;
	}
	
	@RequestMapping("/pass")
	public ModelAndView pass(HttpServletRequest request,HttpServletResponse response,Model model){
		ModelAndView view = new ModelAndView("/p/pass");
		priviligeControllerLogger.info("<|>"+className+"<|>pass<|><|><|>");
		return view;
	}
	
	@RequestMapping("/pass/{newPs}/{oldPs}")
	public @ResponseBody String edit(HttpServletRequest request,HttpServletResponse response,
			@PathVariable String newPs,@PathVariable String oldPs){
		String result = "-1" ;
		if(StringUtils.isNotBlank(newPs) && StringUtils.isNotBlank(oldPs) && newPs.length() >= 6){
			result = "0";
		}
		priviligeControllerLogger.info("<|>"+className+"<|>edit<|>"+oldPs+"<|>"+result+"<|>");
		return result;
	}
	
	@RequestMapping("/u/toadd")
	public ModelAndView nopage(HttpServletRequest request,HttpServletResponse response,Model model){
		ModelAndView view = new ModelAndView("/p/u/add");
		priviligeControllerLogger.info("<|>"+className+"<|>pass<|><|><|>");
		return view;
	}
}
